package matchthreegame.handlers;

import matchthreegame.extensions.MatchThreeGameRoomExtension;
import matchthreegame.gameLogic.GameSwap;

import com.smartfoxserver.v2.entities.User;
import com.smartfoxserver.v2.entities.data.ISFSObject;
import com.smartfoxserver.v2.entities.data.SFSObject;
import com.smartfoxserver.v2.extensions.BaseClientRequestHandler;

public class SendSwapRequestHandler extends BaseClientRequestHandler {
	
	
	MatchThreeGameRoomExtension roomExtension;
	
	@Override
	public void handleClientRequest(User user, ISFSObject params) {
				
		roomExtension = (MatchThreeGameRoomExtension)getParentExtension();
		
		//Make move only if its this player turn
		if ( roomExtension.getCurrentPlayerID() == user.getPlayerId() ) {
			GameSwap swap = new GameSwap((SFSObject)params);
//			trace("Swap send: " + swap);

			trace( user.getName() + " - made move");
			
			roomExtension.performSwap(swap, user.getPlayerId());
		}

	}

}
